package com.acme.bankapp.domain.bank;

import com.acme.bankapp.exceptions.NotEnoughFundsException;

public class SavingsAccount extends AbstractAccount {
	private static final long serialVersionUID = -4360480189051382861L;

	public SavingsAccount(double balance) throws IllegalArgumentException {
		super(balance);
	}
	
	public void withDraw(double x) throws IllegalArgumentException, NotEnoughFundsException {
		if (x <= 0)
			throw new IllegalArgumentException(MES_NEGATIVE_DEPOSIT);
		else if (balance < x) 
			throw new NotEnoughFundsException(MES_TOO_SMALL_BALANCE);
		
		balance -= x;
	}

	@Override
	public double maximumAmountToWithdraw() {
		return balance;
	}	
	
	public double getBalance() {
		return balance;
	}
		
	public String toString() {
		return "Account:" + "balance = " + decimalValue();
	}
}
